<script setup>
import DragArea from '../../components/DragArea.vue'
import FileTable from '../../components/FileTable.vue'
import { useUpload } from '@cp/useUpload'
const exts = ['.jpg', '.jpeg', '.bmp', '.webp', '.gif', '.png'];
const maxSize = 1024 ** 2;
const tableData = ref([])
const { files, addFiles } = useUpload([], exts, maxSize)


const upload = () => {
    console.log('upload')
}
onMounted(() => {
    let obj = {
        name: 'test',
        type: 'jpg',
        size: 1024,
        status: 'success'
    }
    tableData.value.push(obj)
})
</script>

<template>
    <div class="upload">
        <!-- 拖拽 -->
        <DragArea class="drag" :exts="exts" :maxSize="maxSize" @drop="addFiles(...$event)" />
        <!-- 选择 -->
        <div class="select">
            <el-button type="primary">选择文件</el-button>
            <el-button type="primary">选择文件夹</el-button>
        </div>
        <!-- 上传文件列表 -->
        <div class="list">
          <FileTable :tableData="files" />
        </div>
        <!-- 上传文件数量 -->
        
        <!-- 上传按钮 -->
        <div class="button">
            <el-button type="primary" @click="upload">开始上传</el-button>
        </div>
    </div>
</template>

<style lang="scss" scoped>
.upload{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    margin: auto;
    padding: 20px;
    box-sizing: border-box;
    gap: 20px;
    .select{
        display: flex;
        gap: 20px;
        :deep(.el-button){
            width: fit-content;
            padding:6px 10px !important;
            font-size: 14px !important;
            border-radius: 6px !important;
        }
    }
    .list{
        display: flex;
        flex-direction: column;
        height: calc(100% - 400px);
    }

    .button{
        :deep(.el-button){
            width: fit-content;
            padding:6px 10px !important;
            font-size: 14px !important;
            border-radius: 6px !important;
        }
    }
}
</style>